<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%credit_order_log}}".
 *
 * @property int $id
 * @property int $credit_order_id
 * @property int $time
 * @property string $app_post_data
 * @property string $post_data
 * @property string $send_return_msg
 * @property string $credit_order_data
 * @property int $old_status
 * @property int $new_status
 * @property string $api_return_code
 * @property string $api_return_msg
 * @property string $serial_number 流水号
 * @property string $c_name
 * @property string $c_id_card
 * @property string $c_mobile
 * @property string $big_data_validate_detail_swift_number
 * @property string $big_data_validate_person_recognition_shift_number
 * @property string $big_data_validate_return
 *
 * @property BankBackSendLog[] $bankBackSendLogs
 * @property CreditOrder $creditOrder
 */
class CreditOrderLog extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%credit_order_log}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['credit_order_id', 'time', 'serial_number'], 'required'],
            [['credit_order_id', 'time', 'old_status', 'new_status'], 'integer'],
            [['app_post_data', 'post_data', 'credit_order_data', 'api_return_msg', 'big_data_validate_return'], 'string'],
            [['send_return_msg', 'api_return_code'], 'string', 'max' => 10],
            [['serial_number'], 'string', 'max' => 20],
            [['c_name'], 'string', 'max' => 100],
            [['c_id_card'], 'string', 'max' => 19],
            [['c_mobile'], 'string', 'max' => 11],
            [['big_data_validate_detail_swift_number', 'big_data_validate_person_recognition_shift_number'], 'string', 'max' => 50],
            [['credit_order_id'], 'exist', 'skipOnError' => true, 'targetClass' => CreditOrder::className(), 'targetAttribute' => ['credit_order_id' => 'id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'credit_order_id' => Yii::t('app', 'Credit Order ID'),
            'time' => Yii::t('app', 'Time'),
            'app_post_data' => Yii::t('app', 'App Post Data'),
            'post_data' => Yii::t('app', 'Post Data'),
            'send_return_msg' => Yii::t('app', 'Send Return Msg'),
            'credit_order_data' => Yii::t('app', 'Credit Order Data'),
            'old_status' => Yii::t('app', 'Old Status'),
            'new_status' => Yii::t('app', 'New Status'),
            'api_return_code' => Yii::t('app', 'Api Return Code'),
            'api_return_msg' => Yii::t('app', 'Api Return Msg'),
            'serial_number' => Yii::t('app', '流水号'),
            'c_name' => Yii::t('app', 'C Name'),
            'c_id_card' => Yii::t('app', 'C Id Card'),
            'c_mobile' => Yii::t('app', 'C Mobile'),
            'big_data_validate_detail_swift_number' => Yii::t('app', 'Big Data Validate Detail Swift Number'),
            'big_data_validate_person_recognition_shift_number' => Yii::t('app', 'Big Data Validate Person Recognition Shift Number'),
            'big_data_validate_return' => Yii::t('app', 'Big Data Validate Return'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getBankBackSendLogs()
    {
        return $this->hasMany(BankBackSendLog::className(), ['for_serial_number' => 'serial_number']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getCreditOrder()
    {
        return $this->hasOne(CreditOrder::className(), ['id' => 'credit_order_id']);
    }
}
